import { _decorator, Component, Label, Sprite, SpriteFrame, SpriteAtlas } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('Item')
export class Item extends Component {
    @property(Label)
    public lab_num = null;
    @property(Label)
    public lab_name = null;
    @property(Label)
    public lab_score = null;
    @property(Sprite)
    public sp_touxinag = null;
    @property(SpriteFrame)
    public spf_bg = null;
    @property(SpriteAtlas)
    public spa_touXiang = null;

    onLoad () {
    }

    init (num: any, name: any, score: any, touxing: any) {
        this.lab_num.string = num 
        this.lab_name.string = name 
        this.lab_score.string = score 
        if(num % 2 == 0){ 
            this.node.getComponent(Sprite).spriteFrame = this.spf_bg 
        } 
        this.sp_touxinag.spriteFrame = this.spa_touXiang.getSpriteFrame('tou_'+touxing) 
    }

    update (dt: any) {
    }

}


/**
 * 注意：已把原脚本注释，由于脚本变动过大，转换的时候可能有遗落，需要自行手动转换
 */
// cc.Class({
//     extends: cc.Component,
// 
//     properties: {
//         lab_num:cc.Label,
//         lab_name:cc.Label,
//         lab_score:cc.Label,
//         sp_touxinag:cc.Sprite,
//         spf_bg:cc.SpriteFrame,
//         spa_touXiang:cc.SpriteAtlas,
//     },
// 
//     onLoad () {
//         
//     },
// 
//     init:function(num,name,score,touxing){
//         this.lab_num.string = num
//         this.lab_name.string = name
//         this.lab_score.string = score
//         if(num % 2 == 0){
//             this.node.getComponent(cc.Sprite).spriteFrame = this.spf_bg
//         }
//         this.sp_touxinag.spriteFrame = this.spa_touXiang.getSpriteFrame('tou_'+touxing)
//     },
// 
//     update (dt) {
// 
//     },
// });
